//
//  AnimationRoundedCornerViewController.m
//  UITest
//
//  Created by wp w on 12-6-6.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "AnimationRoundedCornerViewController.h"
#import "roundedCornerView.h"

@interface AnimationRoundedCornerViewController ()

@end

@implementation AnimationRoundedCornerViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGPoint frameCenter = self.view.center;
	float width  = 50;
	float height = 50;
	
	CGRect viewFrame = CGRectMake(frameCenter.x-width, frameCenter.y-height,width*2, height*2);
	roundedCornerView *myView = [[roundedCornerView alloc] initWithFrame:viewFrame];
	
	myView.backgroundColor = [UIColor blueColor];
	[[self view] addSubview:myView];
	
	CGRect subViewFrame = CGRectInset(myView.bounds,width/2,height/2);
	roundedCornerView *mySubview = [[roundedCornerView alloc] initWithFrame:subViewFrame];
	mySubview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
	mySubview.backgroundColor = [UIColor yellowColor];
	[myView addSubview:mySubview];	
	
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1.0];
	
	viewFrame = CGRectInset(viewFrame, -width, -height);
	[myView setFrame:viewFrame];
	
	[UIView commitAnimations];
	
	[mySubview release];
	[myView release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
